package com.zxt.spring_ai_demo.tool;

import java.util.function.Function;

public class WeatherService implements Function<WeatherService.WeatherRequest, WeatherService.WeatherResponse> {
    public enum Unit { C, F }
    public record WeatherRequest(String location, Unit unit) {}
    public record WeatherResponse(double temp, Unit unit) {}


    public WeatherResponse apply(WeatherRequest request) {
        if ("北京".equals(request.location)){
            System.out.println("--北京---");
            return new WeatherResponse(10.0,Unit.C);
        }else if ("上海".equals(request.location)) {
            System.out.println("--上海---");
            return new WeatherResponse(20.0, Unit.C);
        }else {
            System.out.println("--其它---");
            return new WeatherResponse(30.0, Unit.C);
        }
    }
}

